package com.xnyzc.lhy.finance.controller.payment;


import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.finance.service.payment.IOaDBehalfPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * <p>
 * 司机钱包表 前端控制器
 * </p>
 *
 * @author cuixiaojian
 * @since 2019-10-20
 */
@RestController
@RequestMapping("/finance/oa-dbehalf-pay")
public class OaDBehalfPayController {

    @Autowired
    private IOaDBehalfPayService iOaDBehalfPayService;

    /**
     * 为司机垫付
     * @param amount 垫付金额
     * @return Map
     */
    @PostMapping("behalfDriverPayment")
    public Rv behalfDriverPayment(
            @RequestParam("amount")BigDecimal amount,
            @RequestParam("orderNo") Long orderNo,
            @RequestParam("didiOrderId") Long didiOrderId
            ) {
        Long driverId = TokenUtil.getTokenUserId();
        return iOaDBehalfPayService.behalfDriverPayment(driverId, amount, orderNo, didiOrderId);
    }

    /**
     * 司机垫付回款
     * @return Map
     */
    @PostMapping("driverPaid")
    public Rv driverPaid(
            @RequestParam("orderNo")Long orderNo,
            @RequestParam("didiOrderId")Long didiOrderId
    ) {
        Long driverId = TokenUtil.getTokenUserId();
        return iOaDBehalfPayService.driverPaid(driverId, orderNo, didiOrderId);
    }

}
